// 各组件
import Layout from '@/layout/index.vue'
import user from '@/layout/user.vue'
import Home from '@/views/Home/index.vue'
import Search from '@/views/Search/index.vue'
import Detail from '@/views/Detail/index.vue'
import AddCartOk from '@/views/Cart/add-cart-ok.vue'
import Cart from '@/views/Cart/index.vue'
import Trade from '@/views/Trade/index.vue'
import Login from '@/views/Login/index.vue'
import Register from '@/views/Register/index.vue'
import myOrder from '@/views/myOrder/index.vue'
import pay from '@/views/pay/index.vue'
import paySuccess from '@/views/pay/paySuccess.vue'

export const routes = [
  {
    path: '/',
    component: Layout,
    redirect: 'home',
    children: [
      {
        path: '/home',
        component: Home
      },
      {
        name: 'search',
        path: '/search/:keyword?',
        component: Search
      },
      {
        name: 'Detail',
        path: '/Detail/:goodsId',
        component: Detail,
        props: true
      },
      {
        name: 'AddCartOk',
        path: '/AddCartOk',
        component: AddCartOk,
        props: true,
      },
      {
        name: 'Cart',
        path: '/cart',
        component: Cart,
      },
      {
        name: 'Trade',
        path: '/trade',
        component: Trade,
        meta: { isRole: true }
      },
      {
        name: 'MyOrder',
        path: '/myOrder',
        component: myOrder,
        meta: { isRole: true }
      },
      {
        name: 'Pay',
        path: '/pay',
        component: pay,
        meta: { isRole: true }
      },
      {
        name: 'PaySuccess',
        path: '/paySuccess',
        component: paySuccess,
        meta: { isRole: true }
      },
    ]
  },
  {
    path: '/Login',
    component: user,
    children: [
      {
        path: '/',
        component: Login
      },
      {
        path: '/Register',
        component: Register
      }
    ]
  },
]
